/**
 * Created by szc on 2017/1/10.
 */
class CrystalDisS extends egret.DisplayObjectContainer {
    private url: any;
    private context: any;
    private numPanle: NumPanel2;
    private image_top:eui.Image;
    private cp:CrystalPanle;
    public constructor(url: any, context: any, cp: CrystalPanle) {
        super();
        this.url = url;
        this.context = context;
        this.cp = cp;
        this.onAddToStage();
        // this.addEventListener(egret.Event.ADDED_TO_STAGE, this.onAddToStage, this);
    }
    private onAddToStage() {

        var crystalPanle = this.context;
        //设置总赢得的图像
        var _group = this;
        //     var imagebg = new eui.Image();
        //     imagebg.source = "lottery_frame_b_png";
        //     imagebg.width = this.bHeight * 1.3;
        //     imagebg.height = this.bHeight * 0.7;
        //     this.addChild(imagebg);
        //     var image = new eui.Image();
        //     image.source = this.url;
        //    if (this.url == "lottery_multiple_png") {
        //         image.width = this.bHeight * 1.2 ;
        //     } else {
        //         image.width = this.bHeight *1.2;
        //     }
        //     image.height = this.bHeight * 0.25 * 0.75;
        //     image.y = 5;
        //     image.x = (imagebg.width - image.width) / 2;;
        //     this.addChild(image);

        var image_bg = new eui.Image();
        image_bg.source = "has_kuang_png";
        image_bg.y = 0;
        image_bg.x = 0;
        image_bg.width = 376;
        image_bg.height = 100;
        image_bg.$setScaleX(0.6);
        image_bg.$setScaleY(0.6);
        _group.addChild(image_bg);

        this.width = image_bg.width*0.6;
        this.height = image_bg.height;


        var image_top = this.image_top = new eui.Image();
        image_top.source = this.url;
        image_top.addEventListener(egret.Event.COMPLETE,this.topLoadComplete,this);
        image_top.$setScaleX(0.6);
        image_top.$setScaleY(0.6);
        _group.addChild(image_top);

        this.numPanle = new NumPanel2(15 * 0.8, 22.5 * 0.8, "w_");
        this.numPanle.setNum(0);
        this.numPanle.x = 115;
        this.numPanle.y = 30;
        this.addChild(this.numPanle);

        if(this.url == "all_bet_top_png")
        {
            this.addEventListener(egret.TouchEvent.TOUCH_BEGIN,this.beginEvent,this);
            this.addEventListener(egret.TouchEvent.TOUCH_END,this.endEvent,this);
        }

    }

    private topLoadComplete(evt:egret.Event)
    {
        this.image_top.y = -25;
        this.image_top.x = this.width/2 - this.image_top.width*0.6/2;
        if(this.url == "all_bet_top_png")
        {
            this.image_top.y = -30;
        }

    }

    public setNum(num: any): void {
        this.numPanle.setNum(num);
        // this.numPanle.x = (this.bWidth * 1.1 - this.numPanle.width) / 2 + this.numPanle.width;
    }
    public getNum() {
        return this.numPanle.getNum();
    }

    private beginEvent(evt:egret.Event)
    {
        this.scaleX = 0.96;
        this.scaleY = 0.96;
    }

    private endEvent(evt:egret.Event)
    {
        this.scaleX = 1;
        this.scaleY = 1;
        this.cp.context.moreBtn.moreUI.setBetShow();
        this.cp.context.moreBtn.visibleMore();
        this.cp.context.soundctr.playSound("click_mp3");

    }

    public setAllBetTouchEvent(enable:boolean)
    {
        this.touchEnabled = enable;
        this.touchChildren = enable;
    }

}